<template>
    <link rel="stylesheet" href="/layui/css/layui.css">

    <div class="content">
        <form class="layui-form">
            <h1 class="title">{{title}}</h1>
            <div class="demo-login-container">
                <div class="layui-form-item">
                    <div class="layui-input-wrap">
                        <div class="layui-input-prefix">
                            <i class="layui-icon layui-icon-username"></i>
                        </div>
                        <input type="text" name="username" placeholder="用户名" autocomplete="off" required
                            class="layui-input" lay-affix="clear" value="bang">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-wrap">
                        <div class="layui-input-prefix">
                            <i class="layui-icon layui-icon-password"></i>
                        </div>
                        <input type="password" name="password" placeholder="密   码" autocomplete="off" required
                            class="layui-input" lay-affix="eye" value="bang">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-row">
                        <div class="layui-col-xs7">
                            <div class="layui-input-wrap">
                                <div class="layui-input-prefix">
                                    <i class="layui-icon layui-icon-vercode"></i>
                                </div>
                                <input type="text" required name="captcha" placeholder="验证码" autocomplete="off"
                                    class="layui-input" lay-affix="clear" value="123">
                            </div>
                        </div>
                        <div class="layui-col-xs5">
                            <div style="margin-left: 10px;">
                                <img src="https://www.oschina.net/action/user/captcha"
                                    onclick="this.src='https://www.oschina.net/action/user/captcha?t='+ new Date().getTime();">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid" type="submit">登录</button>
                </div>
            </div>
        </form>
    </div>

</template>
<script>
    let $ = (query) => layui.$(query, dom.shadow)
    let form = layui.form;
    let layer = layui.layer;
    // 标题
    let title = "Bang 后台管理系统"

    onMethods(function () {
        layui.use(["fn"], function () {
            let fn = layui.fn

            $(".layui-form").submit(function () {
                // 获取表单数据
                let data = fn.formData($(".layui-form"))
                layui.data('user', {
                    key: 'token',
                    value: '模拟token数据'
                });
                layer.msg("登录成功",
                    { icon: 1, time: 1000 },
                    function () {
                        window.location.href = "#/"
                    })
                return false
            })
        })

    })
</script>
<style>
    .demo-login-container {
        width: 320px;
        margin: 21px auto 0;
    }

    .demo-login-other .layui-icon {
        position: relative;
        display: inline-block;
        margin: 0 2px;
        top: 2px;
        font-size: 26px;
    }

    .content {
        position: fixed;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: url(/assets/images/logo_bg.jpg) no-repeat center;
    }

    .content .title {
        color: #16baaa;
    }
</style>